package com.molichuxing.services.infrastructure.convertor;

import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject;
import com.molichuxing.framework.utils.CollectionUtils;
import com.molichuxing.framework.utils.DateUtil;
import com.molichuxing.services.business.dto.request.modify.MaintenanceModifyDto;
import com.molichuxing.services.infrastructure.bean.*;
import com.molichuxing.services.infrastructure.dto.request.create.*;
import com.molichuxing.services.infrastructure.dto.request.modify.*;
import com.molichuxing.services.infrastructure.dto.response.*;
import com.molichuxing.services.property.CarCheckStatusEnum;
import com.molichuxing.services.property.CarYearlyInspectStatusEnum;
import com.molichuxing.services.property.YearlyInspectHandleStatusEnum;
import com.molichuxing.services.property.YearlyInspectHandleWayEnum;
import org.springframework.beans.BeanUtils;

import java.time.LocalDate;
import java.time.LocalDateTime;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;

public class Convert {

    // 车辆检验
    public static CheckDto toCheckBeanDto(CheckBean bean) {
        CheckDto beanDto = null;
        if (bean != null) {
            beanDto = new CheckDto();
            BeanUtils.copyProperties(bean, beanDto);
            String carCheckInfo = bean.getCarCheckInfo();
            if (null != carCheckInfo) {
                beanDto.setCarCheckInfo(JSONObject.parseObject(carCheckInfo, UsedcarCheckInfoDto.class));
            }
        }
        return beanDto;
    }

    // 车辆检验
    public static CheckBean toCheckBean(CheckDto dto) {
        CheckBean bean = null;
        if (dto != null) {
            bean = new CheckBean();
            BeanUtils.copyProperties(dto, bean);
            if (null != dto.getCarCheckInfo()) {
                bean.setCarCheckInfo(JSON.toJSONString(dto.getCarCheckInfo()));
            }
        }
        return bean;
    }

    // 车辆检验列表数据转换
    public static List<CheckDto> toCheckPageBeanDto(List<CheckBean> beanList) {
        List<CheckDto> dtoList = null;
        if (beanList != null && beanList.size() > 0) {
            dtoList = new ArrayList<>();
            for (CheckBean bean : beanList) {
                dtoList.add(toCheckBeanDto(bean));
            }
        }
        return dtoList;
    }

    // 检验图片转换
    public static List<CheckImageDto> toCheckImageDtoList(List<CheckImageBean> beanList) {
        List<CheckImageDto> dtoList = null;
        if (beanList != null && beanList.size() > 0) {
            dtoList = new ArrayList<>();
            for (CheckImageBean bean : beanList) {
                dtoList.add(toCheckImageDto(bean));
            }
        }
        return dtoList;
    }

    // 车辆基础信息转换
    public static CheckImageDto toCheckImageDto(CheckImageBean bean) {
        CheckImageDto beanDto = null;
        if (bean != null) {
            beanDto = new CheckImageDto();
            BeanUtils.copyProperties(bean, beanDto);
        }
        return beanDto;
    }

    // 车辆基础信息转换

    public static List<CarDto> toCarBeanDto(List<CarBean> beanList) {
        List<CarDto> dtoList = null;
        ;
        if (beanList != null && beanList.size() > 0) {
            dtoList = new ArrayList<>();
            for (CarBean bean : beanList) {
                dtoList.add(toCarBeanDto(bean));
            }
        }

        return dtoList;
    }

    public static CarDto toCarBeanDto(CarBean bean) {
        CarDto beanDto = null;
        if (bean != null) {
            beanDto = new CarDto();
            BeanUtils.copyProperties(bean, beanDto);
        }
        return beanDto;
    }

    // 车辆检验争议转换
    public static CheckDisputeDto toCheckDisputeDto(CheckDisputeBean bean) {
        CheckDisputeDto beanDto = null;
        if (bean != null) {
            beanDto = new CheckDisputeDto();
            BeanUtils.copyProperties(bean, beanDto);
        }
        return beanDto;
    }

    public static List<CarDetailDto> toCarDetailDto(List<CarDetailBean> beanList) {
        List<CarDetailDto> dtoList = null;
        if (beanList != null && beanList.size() > 0) {
            dtoList = new ArrayList<>();
            for (CarDetailBean bean : beanList) {
                dtoList.add(toCarDetailDto(bean));
            }
        }

        return dtoList;
    }

    // 车辆详情信息转换
    public static CarDetailDto toCarDetailDto(CarDetailBean bean) {
        CarDetailDto beanDto = null;
        if (bean != null) {
            beanDto = new CarDetailDto();
            BeanUtils.copyProperties(bean, beanDto);
        }
        return beanDto;
    }

    // 检验图片转bean
    public static CheckImageBean toCheckImageBean(Integer checkId, CheckImageModifyDto dto) {
        CheckImageBean beanDto = null;
        if (dto != null) {
            beanDto = new CheckImageBean();
            BeanUtils.copyProperties(dto, beanDto);
            beanDto.setCheckId(checkId);
        }
        return beanDto;
    }

    // 车辆整备信息转换
    public static CheckPreparationDto toCheckPreparationDto(CheckPreparationBean bean) {
        CheckPreparationDto beanDto = null;
        if (bean != null) {
            beanDto = new CheckPreparationDto();
            BeanUtils.copyProperties(bean, beanDto);
        }
        return beanDto;
    }

    // 车辆整备信息转换为bean
    public static CheckPreparationBean toCheckPreparationBean(Integer checkId, CheckPreparationModifyDto dto) {
        CheckPreparationBean beanDto = null;
        if (dto != null) {
            beanDto = new CheckPreparationBean();
            BeanUtils.copyProperties(dto, beanDto);
            beanDto.setId(checkId);
        }
        return beanDto;
    }

    /******************************************** mybits-plus分页结果转换开始 *****************************/
    public static List<CarDto> toCarInfoBeanDto(List<CarBean> beanList) {
        List<CarDto> dtoList = null;
        ;
        if (beanList != null && beanList.size() > 0) {
            dtoList = new ArrayList<>();
            for (CarBean bean : beanList) {
                dtoList.add(toCarInfoBeanDto(bean));
            }
        }

        return dtoList;
    }

    public static CarDto toCarInfoBeanDto(CarBean bean) {
        CarDto beanDto = null;
        if (bean != null) {
            beanDto = new CarDto();
            BeanUtils.copyProperties(bean, beanDto);
        }
        return beanDto;
    }

    /******************************************** mybits-plus分页结果转换结束 *****************************/

    /******************************************** 车牌信息转换开始 *****************************/
    public static LicencePlateDto toLicencePlateDto(LicencePlateBean bean) {
        LicencePlateDto beanDto = null;
        if (bean != null) {
            beanDto = new LicencePlateDto();
            BeanUtils.copyProperties(bean, beanDto);
        }
        return beanDto;
    }

    public static LicencePlateBean toLicencePlateBean(LicencePlateCreateDto bean) {
        LicencePlateBean beanDto = null;
        if (bean != null) {
            beanDto = new LicencePlateBean();
            BeanUtils.copyProperties(bean, beanDto);
        }
        return beanDto;
    }

    public static LicencePlateBean toLicencePlateBean(LicencePlateModifyDto bean) {
        LicencePlateBean beanDto = null;
        if (bean != null) {
            beanDto = new LicencePlateBean();
            BeanUtils.copyProperties(bean, beanDto);
        }
        return beanDto;
    }

    /******************************************** 车牌信息转换开始 *****************************/

    /******************************************** 年检信息转换开始 *****************************/
    public static YearlyInspectionDto toYearlyInspectDto(YearlyInspectionBean bean) {
        YearlyInspectionDto beanDto = null;
        if (bean != null) {
            beanDto = new YearlyInspectionDto();
            BeanUtils.copyProperties(bean, beanDto);
            beanDto.setStatusStr(CarYearlyInspectStatusEnum.getName(bean.getStatus()));
            Integer handleStatus = bean.getHandleStatus();
            if (handleStatus != null) {
                beanDto.setHandleStatusStr(YearlyInspectHandleStatusEnum.getName(handleStatus));
            }
        }
        return beanDto;
    }

    public static YearlyInspectionBean toYearlyInspectionBean(YearlyInspectionCreateDto bean) {
        YearlyInspectionBean beanDto = null;
        if (bean != null) {
            beanDto = new YearlyInspectionBean();
            BeanUtils.copyProperties(bean, beanDto);
            if (null != beanDto.getEndDate()) {
                LocalDateTime endDate = beanDto.getEndDate();
                LocalDate date = DateUtil.lastDayOfMonth(endDate.toLocalDate());
                beanDto.setEndDate(DateUtil.getDayEnd(date));
            }
        }
        return beanDto;
    }

    public static YearlyInspectionBean toYearlyInspectionBean(YearlyInspectionModifyDto bean) {
        YearlyInspectionBean beanDto = null;
        if (bean != null) {

            beanDto = new YearlyInspectionBean();
            BeanUtils.copyProperties(bean, beanDto);
            if (null != beanDto.getEndDate()) {
                LocalDateTime endDate = beanDto.getEndDate();
                LocalDate date = DateUtil.lastDayOfMonth(endDate.toLocalDate());
                beanDto.setEndDate(DateUtil.getDayEnd(date));
            }
        }
        return beanDto;
    }

    public static void main(String[] args) {
        LocalDateTime ss = DateUtil.parseDateTime("2019-11-01 00:00:00");
        LocalDate date = DateUtil.lastDayOfMonth(ss.toLocalDate());
        DateUtil.getDayEnd(date);
    }

    public static List<YearlyInspectionDto> toYearlyInspectionDto(List<YearlyInspectionBean> beanList) {
        List<YearlyInspectionDto> dtoList = null;
        ;
        if (beanList != null && beanList.size() > 0) {
            dtoList = new ArrayList<>();
            for (YearlyInspectionBean bean : beanList) {
                dtoList.add(toYearlyInspectionDto(bean));
            }
        }

        return dtoList;
    }

    public static YearlyInspectionDto toYearlyInspectionDto(YearlyInspectionBean bean) {
        YearlyInspectionDto beanDto = null;
        if (bean != null) {
            beanDto = new YearlyInspectionDto();
            BeanUtils.copyProperties(bean, beanDto);
            Integer handleStatus = bean.getHandleStatus();
            if (handleStatus != null) {
                beanDto.setHandleStatusStr(YearlyInspectHandleStatusEnum.getName(handleStatus));
            }
        }
        return beanDto;
    }

    public static CheckDisputeBean toCheckDisputeBean(CheckDisputeCreateDto dto) {
        CheckDisputeBean bean = null;
        if (dto != null) {
            bean = new CheckDisputeBean();
            BeanUtils.copyProperties(dto, bean);
        }
        return bean;
    }


    public static CheckDisputeBean toCheckDisputeBean(CheckDisputeModifyDto checkDisputeModifyDto, CheckDisputeBean checkDisputeBean) {
        if (checkDisputeModifyDto != null) {
            BeanUtils.copyProperties(checkDisputeModifyDto, checkDisputeBean);
        }
        return checkDisputeBean;
    }

    public static YearlyInspectionLogBean toYearlyInspectionLogBean(YearlyInspectionLogCreateDto bean) {
        YearlyInspectionLogBean beanDto = null;
        if (bean != null) {
            beanDto = new YearlyInspectionLogBean();
            BeanUtils.copyProperties(bean, beanDto);
            if (null != beanDto.getEndDate()) {
                LocalDateTime endDate = beanDto.getEndDate();
                LocalDate date = DateUtil.lastDayOfMonth(endDate.toLocalDate());
                beanDto.setEndDate(DateUtil.getDayEnd(date));
            }
        }
        return beanDto;
    }

    public static List<YearlyInspectionLogDto> toYearlyInspectionLogDto(List<YearlyInspectionLogBean> beanList) {
        List<YearlyInspectionLogDto> dtoList = null;
        ;
        if (beanList != null && beanList.size() > 0) {
            dtoList = new ArrayList<>();
            for (YearlyInspectionLogBean bean : beanList) {
                dtoList.add(toYearlyInspectionLogDto(bean));
            }
        }

        return dtoList;
    }

    public static YearlyInspectionLogDto toYearlyInspectionLogDto(YearlyInspectionLogBean bean) {
        YearlyInspectionLogDto beanDto = null;
        if (bean != null) {
            beanDto = new YearlyInspectionLogDto();
            BeanUtils.copyProperties(bean, beanDto);
            Integer handleWay = bean.getHandleWay();
            if (handleWay != null) {
                beanDto.setHandleWayStr(YearlyInspectHandleWayEnum.getName(handleWay));
            }
        }
        return beanDto;
    }

    public static List<YearlyInspectionBean> toYearlyInspectionBeanList(List<YearlyInspectionModifyDto> beanList) {
        List<YearlyInspectionBean> dtoList = null;
        if (beanList != null && beanList.size() > 0) {
            dtoList = new ArrayList<>();
            for (YearlyInspectionModifyDto bean : beanList) {
                dtoList.add(toYearlyInspectionBean(bean));
            }
        }

        return dtoList;
    }

    public static List<YearlyInspectionLogBean> toYearlyInspectionLogBeanList(List<YearlyInspectionLogCreateDto> beanList) {
        List<YearlyInspectionLogBean> dtoList = null;
        if (beanList != null && beanList.size() > 0) {
            dtoList = new ArrayList<>();
            for (YearlyInspectionLogCreateDto bean : beanList) {
                dtoList.add(toYearlyInspectionLogBean(bean));
            }
        }

        return dtoList;
    }


    /******************************************** 年检信息转换结束 *****************************/

    /******************************************** 保险信息转换开始 *****************************/

    public static List<InsuranceDto> toInsuranceDto(List<InsuranceBean> beanList) {
        List<InsuranceDto> dtoList = null;
        ;
        if (beanList != null && beanList.size() > 0) {
            dtoList = new ArrayList<>();
            for (InsuranceBean bean : beanList) {
                dtoList.add(toInsuranceDto(bean));
            }
        }

        return dtoList;
    }

    public static InsuranceDto toInsuranceDto(InsuranceBean bean) {
        InsuranceDto beanDto = null;
        if (bean != null) {
            beanDto = new InsuranceDto();
            BeanUtils.copyProperties(bean, beanDto);
        }
        return beanDto;
    }

    public static InsuranceBean toInsuranceBean(InsuranceModifyDto bean) {
        InsuranceBean beanDto = null;
        if (bean != null) {
            beanDto = new InsuranceBean();
            BeanUtils.copyProperties(bean, beanDto);
            beanDto.setId(bean.getInsuranceId());
        }
        return beanDto;
    }

    public static List<InsuranceCommercialDto> toInsuranceCommercialDto(List<InsuranceCommercialBean> beanList) {
        List<InsuranceCommercialDto> dtoList = null;
        ;
        if (beanList != null && beanList.size() > 0) {
            dtoList = new ArrayList<>();
            for (InsuranceCommercialBean bean : beanList) {
                dtoList.add(toInsuranceCommercialDto(bean));
            }
        }

        return dtoList;
    }

    public static InsuranceCommercialDto toInsuranceCommercialDto(InsuranceCommercialBean bean) {
        InsuranceCommercialDto beanDto = null;
        if (bean != null) {
            beanDto = new InsuranceCommercialDto();
            BeanUtils.copyProperties(bean, beanDto);
        }
        return beanDto;
    }

    public static InsuranceCommercialBean toInsuranceCommercialBean(InsuranceCommercialModifyDto bean) {
        InsuranceCommercialBean beanDto = null;
        if (bean != null) {
            beanDto = new InsuranceCommercialBean();
            BeanUtils.copyProperties(bean, beanDto);
        }
        return beanDto;
    }

    public static List<InsuranceCommercialBean> toInsuranceCommercialBeanList(List<InsuranceCommercialCreateDto> dtos) {
        List<InsuranceCommercialBean> dataList = null;
        if (CollectionUtils.isNotEmpty(dtos)) {
            dataList = new ArrayList<>();
            for (InsuranceCommercialCreateDto dto : dtos) {
                dataList.add(toInsuranceCommercialBean(dto));
            }
        }
        return dataList;
    }

    public static InsuranceCommercialBean toInsuranceCommercialBean(InsuranceCommercialCreateDto bean) {
        InsuranceCommercialBean beanDto = null;
        if (bean != null) {
            beanDto = new InsuranceCommercialBean();
            BeanUtils.copyProperties(bean, beanDto);
        }
        return beanDto;
    }

    public static CarDetailBean toCarDetailBean(CarDetailModifyDto bean) {
        CarDetailBean beanDto = null;
        if (bean != null) {
            beanDto = new CarDetailBean();
            BeanUtils.copyProperties(bean, beanDto);
        }
        return beanDto;
    }


    /******************************************** 保险信息转换结束 *****************************/

    /******************************************** 事故信息转换开始 *****************************/
    public static List<AccidentDto> toAccidentBeanDto(List<AccidentBean> beanList) {
        List<AccidentDto> dtoList = null;
        ;
        if (beanList != null && beanList.size() > 0) {
            dtoList = new ArrayList<>();
            for (AccidentBean bean : beanList) {
                dtoList.add(toAccidentBeanDto(bean));
            }
        }

        return dtoList;
    }

    public static AccidentDto toAccidentBeanDto(AccidentBean bean) {
        AccidentDto beanDto = null;
        if (bean != null) {
            beanDto = new AccidentDto();
            BeanUtils.copyProperties(bean, beanDto);
        }
        return beanDto;
    }

    public static List<AccidentCaseDto> toAccidentCaseDto(List<AccidentCaseBean> beanList) {
        List<AccidentCaseDto> dtoList = null;
        ;
        if (beanList != null && beanList.size() > 0) {
            dtoList = new ArrayList<>();
            for (AccidentCaseBean bean : beanList) {
                dtoList.add(toAccidentCaseDto(bean));
            }
        }

        return dtoList;
    }

    public static AccidentCaseDto toAccidentCaseDto(AccidentCaseBean bean) {
        AccidentCaseDto beanDto = null;
        if (bean != null) {
            beanDto = new AccidentCaseDto();
            BeanUtils.copyProperties(bean, beanDto);
        }
        return beanDto;
    }

    public static AccidentDriveDto toAccidentDriveDto(AccidentDriveBean bean) {
        AccidentDriveDto beanDto = null;
        if (bean != null) {
            beanDto = new AccidentDriveDto();
            BeanUtils.copyProperties(bean, beanDto);
        }
        return beanDto;
    }

    public static List<AccidentImageDto> toAccidentImageDto(List<AccidentImageBean> beanList) {
        List<AccidentImageDto> dtoList = null;
        ;
        if (beanList != null && beanList.size() > 0) {
            dtoList = new ArrayList<>();
            for (AccidentImageBean bean : beanList) {
                dtoList.add(toAccidentImageDto(bean));
            }
        }

        return dtoList;
    }

    public static AccidentImageDto toAccidentImageDto(AccidentImageBean bean) {
        AccidentImageDto beanDto = null;
        if (bean != null) {
            beanDto = new AccidentImageDto();
            BeanUtils.copyProperties(bean, beanDto);
        }
        return beanDto;
    }

    public static AccidentBean toAccidentBean(AccidentModifyDto bean) {
        AccidentBean beanDto = null;
        if (bean != null) {
            beanDto = new AccidentBean();
            BeanUtils.copyProperties(bean, beanDto);
        }
        return beanDto;
    }

    public static AccidentCaseBean toAccidentCaseBean(AccidentCaseModifyDto bean) {
        AccidentCaseBean beanDto = null;
        if (bean != null) {
            beanDto = new AccidentCaseBean();
            BeanUtils.copyProperties(bean, beanDto);
        }
        return beanDto;
    }

    /******************************************** 事故信息转换结束 *****************************/

    public static List<CarsViolationDto> toCarsViolationDto(List<CarsViolationBean> beanList) {
        List<CarsViolationDto> dtoList = null;
        if (beanList != null && beanList.size() > 0) {
            dtoList = new ArrayList<>();
            for (CarsViolationBean bean : beanList) {
                dtoList.add(toCarsViolationDto(bean));
            }
        }

        return dtoList;
    }

    public static CarsViolationDto toCarsViolationDto(CarsViolationBean bean) {
        CarsViolationDto beanDto = null;
        if (bean != null) {
            beanDto = new CarsViolationDto();
            BeanUtils.copyProperties(bean, beanDto);
        }
        return beanDto;
    }

    public static AccidentBean toAccidentBean(AccidentCreateDto beanDto) {
        AccidentBean bean = null;
        if (beanDto != null) {
            bean = new AccidentBean();
            BeanUtils.copyProperties(beanDto, bean);
        }
        return bean;
    }

    public static AccidentImageBean toAccidentImageBeanBean(AccidentImageCreateDto beanDto) {
        AccidentImageBean bean = null;
        if (beanDto != null) {
            bean = new AccidentImageBean();
            BeanUtils.copyProperties(beanDto, bean);
        }
        return bean;
    }

    public static AccidentDriveBean toAccidentDriveBean(AccidentDriveCreateDto beanDto) {
        AccidentDriveBean bean = null;
        if (beanDto != null) {
            bean = new AccidentDriveBean();
            BeanUtils.copyProperties(beanDto, bean);
        }
        return bean;
    }

    public static AccidentCaseBean toAccidentCaseBean(AccidentCaseCreateDto beanDto) {
        AccidentCaseBean bean = null;
        if (beanDto != null) {
            bean = new AccidentCaseBean();
            BeanUtils.copyProperties(beanDto, bean);
        }
        return bean;
    }

    /*************************************
     * 保养 开始
     *********************************************/
    public static List<MaintenanceDto> toMaintenanceDto(List<MaintenanceBean> beanList) {
        List<MaintenanceDto> dtoList = null;
        ;
        if (beanList != null && beanList.size() > 0) {
            dtoList = new ArrayList<>();
            for (MaintenanceBean bean : beanList) {
                dtoList.add(toMaintenanceDto(bean));
            }
        }

        return dtoList;
    }

    public static MaintenanceDto toMaintenanceDto(MaintenanceBean bean) {
        MaintenanceDto beanDto = null;
        if (bean != null) {
            beanDto = new MaintenanceDto();
            BeanUtils.copyProperties(bean, beanDto);
        }
        return beanDto;
    }

    public static List<MaintenanceLogDto> toMaintenanceLogDto(List<MaintenanceLogBean> beanList) {
        List<MaintenanceLogDto> dtoList = null;
        ;
        if (beanList != null && beanList.size() > 0) {
            dtoList = new ArrayList<>();
            for (MaintenanceLogBean bean : beanList) {
                dtoList.add(toMaintenanceLogDto(bean));
            }
        }

        return dtoList;
    }

    public static MaintenanceLogDto toMaintenanceLogDto(MaintenanceLogBean bean) {
        MaintenanceLogDto beanDto = null;
        if (bean != null) {
            beanDto = new MaintenanceLogDto();
            BeanUtils.copyProperties(bean, beanDto);
            if (null != bean.getOperationId()) {
                beanDto.setOperationId(bean.getOperationId() + "");
            }
        }
        return beanDto;
    }

    /********************************************
     * 保养 结束
     ****************************************/

    public static CarsViolationBean toCarsViolation(ViolationCreateDto dto) {
        CarsViolationBean bean = null;
        if (dto != null) {
            bean = new CarsViolationBean();
            BeanUtils.copyProperties(dto, bean);
        }
        return bean;
    }

    public static MaintenanceLogBean toMaintenanceLogBean(MaintenanceLogCreateDto dto) {
        MaintenanceLogBean bean = null;
        if (dto != null) {
            bean = new MaintenanceLogBean();
            BeanUtils.copyProperties(dto, bean);
            bean.setOperationId(dto.getOperationId());
        }
        return bean;
    }

    public static MaintenanceLogBean toModifyMaintenanceLogBean(MaintenanceModifyDto dto) {
        MaintenanceLogBean bean = null;
        if (dto != null) {
            bean = new MaintenanceLogBean();
            BeanUtils.copyProperties(dto, bean);
            bean.setId(dto.getMaintenanceLogId());
        }
        return bean;
    }

    public static MaintenanceConfigDto toMaintenanceConfigDto(MaintenanceConfigBean bean) {
        MaintenanceConfigDto dto = null;
        if (bean != null) {
            dto = new MaintenanceConfigDto();
            BeanUtils.copyProperties(bean, dto);
        }
        return dto;
    }

    public static MaintenanceConfigBean toMaintenanceConfigBean(MaintenanceConfigCreateDto dto) {
        MaintenanceConfigBean bean = null;
        if (dto != null) {
            bean = new MaintenanceConfigBean();
            BeanUtils.copyProperties(dto, bean);
        }
        return bean;
    }

    public static MaintenanceConfigBean toMaintenanceConfigBean(MaintenanceConfigModifyDto dto) {
        MaintenanceConfigBean bean = null;
        if (dto != null) {
            bean = new MaintenanceConfigBean();
            BeanUtils.copyProperties(dto, bean);
        }
        return bean;
    }

    /********************************************
     * 保养 结束
     ****************************************/

    public static CarStatisticsDto toCarStatisticsDto(CarStatisticsBean bean) {
        CarStatisticsDto dto = null;
        if (bean != null) {
            dto = new CarStatisticsDto();
            BeanUtils.copyProperties(bean, dto);
        }
        return dto;
    }

    public static CarStatisticsBean toCarStatisticsBean(CarStatisticsCreateDto dto) {

        CarStatisticsBean bean = null;
        if (dto != null) {
            bean = new CarStatisticsBean();
            BeanUtils.copyProperties(dto, bean);
        }
        return bean;
    }

    public static HandoverBean toHandoverBean(HandoverCreateDto createDto) {
        HandoverBean bean = null;
        if (createDto != null) {
            bean = new HandoverBean();
            BeanUtils.copyProperties(createDto, bean);
            bean.setType(createDto.getType().getValue());
        }
        return bean;
    }

    public static HandoverDto toHandoverDto(HandoverBean bean) {
        HandoverDto beanDto = null;
        if (bean != null) {
            beanDto = new HandoverDto();
            BeanUtils.copyProperties(bean, beanDto);
        }
        return beanDto;
    }

    public static HandoverBean toHandoverBean(HandoverModifyDto modifyDto) {
        HandoverBean bean = null;
        if (modifyDto != null) {
            bean = new HandoverBean();
            BeanUtils.copyProperties(modifyDto, bean);
        }
        return bean;
    }

    public static CheckBean toCheckBean(CheckCreateDto createDto) {
        if (createDto == null) {
            return null;
        }
        CheckBean bean = new CheckBean();
        BeanUtils.copyProperties(createDto, bean);
        bean.setType(createDto.getType().getValue());
        bean.setCarType(createDto.getCarType().getValue());
        bean.setStatus(CarCheckStatusEnum.NO_CHECK.getValue());

        return bean;
    }

    public static MaintenanceBean toMaintenanceBean(MaintenanceDto beanDto) {
        MaintenanceBean bean = null;
        if (beanDto != null) {
            bean = new MaintenanceBean();
            BeanUtils.copyProperties(beanDto, bean);
        }
        return bean;
    }

    public static CarBean toCarBean(CarModifyDto dto) {
        CarBean bean = null;
        if (dto != null) {
            bean = new CarBean();
            BeanUtils.copyProperties(dto, bean);
        }
        return bean;
    }


    /******************************************** 车辆围栏异常结果转换开始 *****************************/
    public static List<FenceExceptionDto> toFenceExceptionBeanDto(List<FenceExceptionBean> beanList) {
        List<FenceExceptionDto> dtoList = null;
        ;
        if (beanList != null && beanList.size() > 0) {
            dtoList = new ArrayList<>();
            for (FenceExceptionBean bean : beanList) {
                dtoList.add(toFenceExceptionBeanDto(bean));
            }
        }

        return dtoList;
    }

    public static FenceExceptionDto toFenceExceptionBeanDto(FenceExceptionBean bean) {
        FenceExceptionDto beanDto = null;
        if (bean != null) {
            beanDto = new FenceExceptionDto();
            BeanUtils.copyProperties(bean, beanDto);
        }
        return beanDto;
    }


    public static FenceExceptionBean toFenceExceptionBean(FenceExceptionCreateDto dto) {
        FenceExceptionBean bean = null;
        if (dto != null) {
            bean = new FenceExceptionBean();
            BeanUtils.copyProperties(dto, bean);
        }
        return bean;
    }

    /******************************************** 车辆围栏异常结果转换结束 *****************************/


    /***
     *  车辆监控
     */
    public static List<CarsMileageMonitoringEnterpriseResDto> toListCarsMileageMonitoringDto(List<CarsMileageMonitoringEnterpriseBean> beanList) {
        List<CarsMileageMonitoringEnterpriseResDto> dtoList = null;
        ;
        if (beanList != null && beanList.size() > 0) {
            dtoList = new ArrayList<>();
            for (CarsMileageMonitoringEnterpriseBean bean : beanList) {
                dtoList.add(toCarsMileageMonitoringDto(bean));
            }
        }

        return dtoList;
    }

    public static CarsMileageMonitoringEnterpriseResDto toCarsMileageMonitoringDto(CarsMileageMonitoringEnterpriseBean bean) {
        CarsMileageMonitoringEnterpriseResDto beanDto = null;
        if (bean != null) {
            beanDto = new CarsMileageMonitoringEnterpriseResDto();
            BeanUtils.copyProperties(bean, beanDto);
        }
        return beanDto;
    }

    public static List<WarnConfigBean> toWarnConfigBeanList(List<WarnConfigModifyDto> dtoList) {
        List<WarnConfigBean> list = null;
        if (dtoList != null && dtoList.size() > 0) {
            list = new ArrayList<>();
            for (WarnConfigModifyDto dto : dtoList) {
                list.add(toWarnConfigBean(dto));
            }
        }

        return list;
    }

    public static WarnConfigBean toWarnConfigBean(WarnConfigModifyDto dto) {
        WarnConfigBean bean = null;
        if (dto != null) {
            bean = new WarnConfigBean();
            BeanUtils.copyProperties(dto, bean);
        }
        return bean;
    }

    public static WarnConfigBean toWarnConfigBean(WarnConfigModifyDto dto, WarnConfigBean bean) {
        if (dto != null) {
            BeanUtils.copyProperties(dto, bean);
        }
        return bean;
    }

    public static List<WarnConfigDto> toWarnConfigDtoList(List<WarnConfigBean> beanList) {
        List<WarnConfigDto> list = null;
        if (beanList != null && beanList.size() > 0) {
            list = new ArrayList<>();
            for (WarnConfigBean bean : beanList) {
                list.add(toWarnConfigDto(bean));
            }
        }

        return list;
    }

    public static WarnConfigDto toWarnConfigDto(WarnConfigBean bean) {
        WarnConfigDto dto = null;
        if (bean != null) {
            dto = new WarnConfigDto();
            BeanUtils.copyProperties(bean, dto);
            dto.setWarnConfigId(bean.getId());
        }
        return dto;
    }

    public static List<MaintenanceConfigDto> toMaintenanceConfigDtoList(List<MaintenanceConfigBean> beanList) {
        List<MaintenanceConfigDto> dtoList = null;
        if (beanList != null && beanList.size() > 0) {
            dtoList = new ArrayList<>();
            for (MaintenanceConfigBean bean : beanList) {
                dtoList.add(toMaintenanceConfigDto(bean));
            }
        }

        return dtoList;
    }

    public static StatisticsAssetBean toStatisticsAssetBean(StatisticsAssetCreateDto dto) {
        StatisticsAssetBean bean = null;
        if (dto != null) {
            bean = new StatisticsAssetBean();
            BeanUtils.copyProperties(dto, bean);
        }
        return bean;
    }

    public static List<StatisticsAssetBean> toStatisticsAssetBeanList(List<StatisticsAssetCreateDto> dtoList) {
        if (CollectionUtils.isEmpty(dtoList)) {
            return Collections.emptyList();
        }
        List<StatisticsAssetBean> beanList = new ArrayList<>();
        for (StatisticsAssetCreateDto dto : dtoList) {
            StatisticsAssetBean bean = toStatisticsAssetBean(dto);
            beanList.add(bean);
        }
        return beanList;
    }

    public static List<StatisticsAssetDto> toStatisticsAssetDtoList(List<StatisticsAssetBean> beanList) {
        List<StatisticsAssetDto> dtoList = null;
        if (beanList != null && beanList.size() > 0) {
            dtoList = new ArrayList<>();
            for (StatisticsAssetBean bean : beanList) {
                dtoList.add(toStatisticsAssetDto(bean));
            }
        }

        return dtoList;
    }

    public static StatisticsAssetDto toStatisticsAssetDto(StatisticsAssetBean bean) {
        StatisticsAssetDto beanDto = null;
        if (bean != null) {
            beanDto = new StatisticsAssetDto();
            BeanUtils.copyProperties(bean, beanDto);
        }
        return beanDto;
    }
}
